package org.cug.uav.gcs.waypoints;

import java.util.List;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;

public class WayPointTableProvider extends LabelProvider implements ITableLabelProvider,IStructuredContentProvider {

	@Override
	public Image getColumnImage(Object arg0, int arg1) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getColumnText(Object element, int columnIndex) {
		// TODO Auto-generated method stub
		if (element instanceof WayPoint){
			WayPoint p = (WayPoint)element;
			if(columnIndex == 0){
			return String.valueOf(p.index);
			}else if(columnIndex == 1){
			return p.getLocate().latitude.toString();
			}else if (columnIndex ==2){
			return p.getLocate().longitude.toString();
			}else if (columnIndex == 3){
			return String.valueOf(p.altitude);
			}
		}
		return null;
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
		// TODO Auto-generated method stub
		
	}

	@SuppressWarnings("unchecked")
	@Override
	public Object[] getElements(Object arg0) {
		// TODO Auto-generated method stub
		return ((List<WayPoint>) arg0).toArray();

	}
}
